<template>
    <div class="tmpl">
        <div class="mui-content">
            <ul class="mui-table-view">
                <li v-for="item in newsList" class="mui-table-view-cell mui-media">
                    <router-link :to="'/news/info/'+item.id" class="mui-navigate-right">
                        <img class="mui-media-object mui-pull-left" :src="item.img_url">
                        <div class="mui-media-body">
                            {{item.title}}
                            <p class='mui-ellipsis'>
                                {{item.add_time | dateFmt('YYYY-MM-DD')}}
                                <span>
                                    点击数：{{item.click}}
                                </span>
                            </p>
                        </div>
                    </router-link>
                </li>
            </ul>
        </div>
    </div>
</template>

<style scoped>
    .mui-ellipsis{
        margin-top: 20px;
        font-size: 12px;
        color: #0094ff;
    }

    .mui-ellipsis > span{
        position: absolute;
        top: 50px;
        right: 20px;
    }

    .mui-table-view-cell img{
        height: 63px;
        max-width: 63px;
    }

    .mui-navigate-right:after, .mui-push-right:after{
        content:''
    }
</style>

<script>
    import common from '../../tools/common.js';

    export default{
        data(){
            return {
                newsList : []
            };
        },
        created(){
            console.log("newslist created");
            this.getNewsListData();
        },
        destroyed(){
            console.log("newslist destroyed");
        },
        methods:{
            getNewsListData(){
                //1.url
                const url = common.apihost + "api/getnewslist";

                //2.send request
                this.$http.get(url).then(res=>{
                    //console.log(res.body.message);
                    this.newsList = res.body.message;
                },err=>{

                })
            }
        }
    }
</script>